package cc.decat.escript.ir.expression;

import cc.decat.escript.ir.Visitor;

public class LiteralExpression extends Expression {

    public enum Type {
        Integer,
        Float,
        String
    }

    private Type type;
    private Long integerValue;
    private String stringValue;
    private Double floatValue;


    public Type getType() {
        return type;
    }

    public LiteralExpression setIntegerValue(Long integerValue) {
        this.integerValue = integerValue;
        this.type = Type.Integer;
        return this;
    }

    public LiteralExpression setIntegerValue(Integer integerValue) {
        this.integerValue = Long.valueOf(integerValue);
        this.type = Type.Integer;
        return this;
    }

    public LiteralExpression setFloatValue(Double floatValue) {
        this.floatValue = floatValue;
        this.type = Type.Float;
        return this;
    }
    public LiteralExpression setStringValue(String stringValue) {
        this.stringValue = stringValue;
        this.type = Type.String;
        return this;
    }

    public Long getIntegerValue() {
        return integerValue;
    }

    public Double getFloatValue() {
        return floatValue;
    }

    public String getStringValue() {
        return stringValue;
    }

    @Override
    public void accept(Visitor visitor) {
        visitor.visit(this);
    }
}
